/* 744. 寻找比目标字母大的最小字母 */
/**
 * @param {character[]} letters
 * @param {character} target
 * @return {character}
 */
var nextGreatestLetter = function (letters, target) {
	let left = 0,
		right = letters.length,
		ans = letters[0]
	while (left < right) {
		const mid = left + ((right - left) >> 1)
		if (letters[mid] <= target) {
			left = mid + 1
		} else {
			ans = letters[mid]
			right = mid
		}
	}
	return ans
}

nextGreatestLetter(['c', 'f', 'j'], 'j')
